<template>
  <VDialog
    @close="handleClose"
    @save="save"
    :loading="loading"
    title="修改资金说明"
  >
    <template #content>
      <el-input
        v-model="illustrate"
        :rows="2"
        type="textarea"
        placeholder="资金说明"
      />
    </template>
  </VDialog>
</template>
<script setup>
import { ElMessage } from "element-plus";
import { getCapitalFlowDetail } from "../../api.js";
const props = defineProps({
  id: { type: String, default: "" },
});
const loading = ref(false);
const illustrate = ref(null);
const emit = defineEmits(["update:modelValue", "close", "refresh"]);
const save = async () => {
  try {
    if (!illustrate.value) return ElMessage.error("请输入资金说明");
    const { code, message } = await getCapitalFlowDetail({
      id: props.id,
      illustrate: illustrate.value,
    });
    if (code !== 200) return ElMessage.error(message);
    ElMessage.success("修改成功!");
    handleClose(true);
  } catch (error) {}
};
const handleClose = async (refresh) => {
  illustrate.value = null;
  emit("update:modelValue", false);
  emit("close");
  if (refresh) emit("refresh");
};
</script>
